home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2.sit / Raven 1.2 / Source / Foundation / OS / ZMacDialog.h < prev    next >
Text File  |  1996-11-01  |  3KB  |  96 lines

  1. /*
  2.  *  File:       ZMacDialog.h
  3.  *  Summary:       A class that makes it a bit easier to write toolbox dialog code.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->     7/17/96    JDJ        Created
  12.  */
  13.  
  14. #pragma once
  15.  
  16. #include <Dialogs.h>
  17.  
  18. #include <ZTypes.h>
  19.  
  20.  
  21. // ===================================================================================
  22. //    TMacDialog
  23. // ===================================================================================
  24. class TMacDialog {
  25.  
  26. //-----------------------------------
  27. //    Initialization/Destruction
  28. //
  29. public:
  30.     virtual             ~TMacDialog() = 0;
  31.         
  32.     explicit            TMacDialog(ResID dlogID);
  33.                         // Initialize dialog items in your subclasse's ctor.
  34.  
  35. //-----------------------------------
  36. //    External API
  37. //
  38. public:
  39.     virtual short         Pose();
  40.                         // Returns the number of the item that dismissed the dialog. 
  41.         
  42. //-----------------------------------
  43. //    Frequently Overriden Functions
  44. //
  45. protected:
  46.     virtual bool         CanDismiss();
  47.                         // Return true if it's OK to dismiss the dialog. Default
  48.                         // always returns true.
  49.     
  50.     virtual bool         IsDismisser(short item) const;
  51.                         // Returns true if the dialog item can be used to dismiss the
  52.                         // dialog. Default returns true if item == ok.
  53.                         
  54.     virtual bool         IsValidChar(char ch) const;
  55.                         // Return true if the character is OK. Default always returns
  56.                         // true. Note that this is not called for action keys.
  57.                         
  58.     virtual void         OnClickedItem(short& /*item*/)                {}
  59.                         // Called whenever a dialog item is clicked. You can use this to
  60.                         // maintain state information or handle radio buttons.
  61.         
  62. //-----------------------------------
  63. //    Seldomly Overriden Functions
  64. //
  65. public:
  66.     virtual bool         HandleEventFilter(EventRecord* event, short* item);
  67.                         // Called by the dialog's dialog filter. The loop will terminate
  68.                         // when IsDismisser and CanDismiss return true or when the user
  69.                         // clicks on the cancel button (item #2).
  70.     
  71. protected:
  72.     virtual short         HandleEvents();
  73.                         // The dialog's event loop.
  74.     
  75.     virtual void        Show();
  76.                         // Called by Pose to display the dialog.
  77.     
  78.     virtual void        Hide();
  79.                         // Called by Pose to hide the dialog.
  80.  
  81.     virtual bool         IsValidEvent(const EventRecord& event) const;
  82.  
  83.     virtual bool         IsActionChar(char ch) const;
  84.                         // Returns true if the ch is the Enter, Return, Tab, or Escape key.
  85.  
  86.     virtual bool         IsEditChar(char ch, short key) const;
  87.                         // Returns true if the ch is F2-F4 or an arrow key.
  88.  
  89. //-----------------------------------
  90. //    Member data
  91. //
  92. protected:
  93.     DialogPtr        mDialog;
  94. };
  95.  
  96.